package com.entrogy.service.impl;

import com.entrogy.bean.QuotaSuperviseEntity;
import com.entrogy.bean.UserEntity;
import com.entrogy.dao.QuotaSuperviseMapper;
import com.entrogy.dao.UserMapper;
import com.entrogy.service.QuotaSuperviseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**额度管理service接口实现类
 * @Author 许红松
 * @date 2019/6/17 0017 下午 1:52
 */
@Service("quotaSuperviseService")
public class QuotaSuperviseServiceImpl implements QuotaSuperviseService {

    @Autowired
    private QuotaSuperviseMapper quotaSuperviseMapper;//额度管理dao接口

    @Autowired
    private UserMapper userMapper;//用户管理接口

    /**
     *
     * @param map
     * @return
     */
    @Override
    public List<QuotaSuperviseEntity> getQuotaSuperviseList(Map<String, Object> map) {
        if (!map.containsKey("school_code")){
            if (map.containsKey("dingdingId")){
                UserEntity userEntity=userMapper.getUserById(map.get("dingdingId").toString());
                if (userEntity!=null){
                    map.put("school_code",userEntity.getSchoolCode());
                    map.put("UserId",userEntity.getId());
                }
            }

        }
        return quotaSuperviseMapper.getQuotaSuperviseList(map);
    }
}
